package view.carte;

import java.util.Observable;
import java.util.Observer;

import javax.swing.JLabel;

import server.models.PosteDeTir;
import server.models.tireur.ITireur;

public class PosteDeTirView extends JLabel implements Observer{

	private String nomPosteDeTir = "";

	public PosteDeTirView(PosteDeTir posteDeTir) {
		super();
		this.nomPosteDeTir = "";
		((Observable)posteDeTir).addObserver(this);
		this.setText(this.nomPosteDeTir);
		this.setVisible(true);
		this.repaint();
	}

	@Override
	public void update(Observable observable, Object arg) {
		PosteDeTir posteDeTir = (PosteDeTir)observable;
		
		String text = this.nomPosteDeTir;
		for(ITireur tireur : posteDeTir.getListeTireurs()){
			text += tireur.getSurnom() + " ";
		}
		
		this.setText(text);
		
		this.repaint();
	}
}